//
//  CmtSecAttenModel.m
//  Products_B
//
//  Created by lanou on 16/5/30.
//  Copyright © 2016年 朋学友. All rights reserved.
//

#import "CmtSecAttenModel.h"
#import "CmtSecAttenLike.h"
#import "CmtSecAttenComment.h"
#import "CmtSecAttenRelates.h"
@implementation CmtSecAttenModel

-(instancetype)init{

    if ([super init]) {
        _likeArray = [NSMutableArray arrayWithCapacity:10];
        _commentArray = [NSMutableArray arrayWithCapacity:10];
        _relatesArry = [NSMutableArray arrayWithCapacity:10];
    }
    return self;
}


-(void)setValue:(id)value forUndefinedKey:(NSString *)key{

    if ([key isEqualToString:@"id"]) {
        __id = value;
    }

}

+(NSMutableArray *)setModelWithJsDic:(NSDictionary *)jsdic{

    NSMutableArray *modelArray = [NSMutableArray arrayWithCapacity:10];
    NSDictionary *DataDic = jsdic[@"data"];

    for (NSDictionary *topDic in DataDic[@"topics"]) {
        CmtSecAttenModel *model = [[CmtSecAttenModel alloc]init];
        
        [model setValuesForKeysWithDictionary:DataDic];
        [model setValuesForKeysWithDictionary:topDic];
        
        for (NSDictionary *commentDic in DataDic[@"comment"]) {
            CmtSecAttenComment *model1 = [[CmtSecAttenComment alloc] init];
            [model1 setValuesForKeysWithDictionary:commentDic];
            [model.commentArray addObject:model1];
        }
        
        for (NSDictionary *likeDic in DataDic[@"like"]) {
            CmtSecAttenLike *LikeModel = [[CmtSecAttenLike alloc]init];
            [LikeModel setValuesForKeysWithDictionary:likeDic];
            [model.likeArray addObject:LikeModel];
        }
        for (NSDictionary *relatesDic in DataDic[@"relates"]) {
            CmtSecAttenRelates *relates = [[CmtSecAttenRelates alloc]init];
            [relates setValuesForKeysWithDictionary:relatesDic];
            
        
            
            [model.relatesArry addObject:relates];
           
        }
        
        [modelArray addObject:model];
    }
    return modelArray;
}

@end
